const { DataTypes } = require('sequelize')

const seq = require('../db/seq')

//创建模型(Model koa_User )
const User = seq.define('koa_user', {
    //id会被sequelize自动创建
    user_name: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
        comment: '用户名 ,唯一'
    },
    password: {
        type: DataTypes.CHAR(64),
        allowNull: false,
        comment: "密码"
    },
    IsAdmin: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        comment: '是否为管理员',
        defaultValue: 0
    }
})

//不创建表注释掉 强制同步数据库
// User.sync({ force: true })

module.exports = User